package nc.impl.mes.commit;

import nc.mes.pub.tools.CommonUtil;
import nc.vo.ic.m4i.entity.GeneralOutVO;
import nc.vo.ic.m4k.entity.WhsTransBillHeaderVO;
import nc.vo.org.OrgVO;
import nc.vo.pub.BusinessException;
import nc.vo.pubapp.pattern.model.entity.bill.AbstractBill;

import com.alibaba.fastjson.JSONObject;

public class DataRequest4IUnapprove extends DataRequest{

	@Override
	public String getSendJson(AbstractBill[] bill) throws BusinessException {
		
		 /* 
		 {
  "documentsCode": "TC2025062800034019",
  "erpDocumentsType": "OutWHOrder",
  "inventoryOrganization": "010101"
}
		 */
		JSONObject json = new JSONObject();
		for(int i=0;i<bill.length;i++){
			GeneralOutVO generalInVO= (GeneralOutVO)bill[i];
			WhsTransBillHeaderVO syvo = CommonUtil.getWhstransVO(generalInVO.getChildrenVO()[0].getCsourcebillhid());
			if(syvo==null|| CommonUtil.isEmpty( syvo.getVdef2())){
				continue;
			} 
			String vbillcode = generalInVO.getParentVO().getVbillcode();
			String pk_org = generalInVO.getParentVO().getPk_org();
			OrgVO orgInf = CommonUtil.getOrgInf(pk_org);
			json.put("DocumentsCode", vbillcode);
			json.put("ErpDocumentsType", "OutWHOrder");
			json.put("InventoryOrganization", orgInf.getCode()); 
			
		}
		String result = json.toJSONString();
		return result;
	}

}
